package net.satiri.panaroekan.listener;

import net.satiri.panaroekan.PanaroekanApp;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.util.Log;

public class PanaroekanLocationListener implements LocationListener {

	private Context ctx;
	
	public PanaroekanLocationListener(Context ctx){
		this.ctx = ctx;
	}
	
	@Override
	public void onLocationChanged(Location loc) {
		
		//update global value
		try{
			PanaroekanApp appState = (PanaroekanApp)ctx.getApplicationContext();
			appState.setLastLong(loc.getLongitude()+"");
			appState.setLastLat(loc.getLatitude()+"");		
		}catch(Exception e){
			e.printStackTrace();
		}
		
		Log.i("GPS","Lokasi Berubah " + loc.getLongitude() + "," + loc.getLatitude());
		
		//update latest longlat
	}

	@Override
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub
		Log.i("GPS","GPS OFF");
	}

	@Override
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub
		Log.i("GPS","GPS ON");
	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub
		
	}

}
